package com.example.timer;

import com.example.timer.config.JobConfig;
import com.example.timer.executor.JobExecutor;
import java.util.logging.Logger;

import java.util.concurrent.TimeUnit;
/**
 * @author daiguojun
 */

public class FramelessApplication {


    private static Logger logger = Logger.getLogger(FramelessApplication.class.getName());


    /**
     * 程序入口
     * @param args
     */
    public static void main(String[] args) throws Exception {
        // 模拟程序运行的场景
        try {
             // 程序运行时初始化该方法
            JobConfig.getInstance().initJobExecutor();
            // 只调一次 直接根据 指定的 定时任务注解上指定的value来调度
            JobExecutor.loadJobHandler("test3").execute();
            // Blocks until interrupted
            while (true) {
                try {
                    TimeUnit.HOURS.sleep(1);
                } catch (InterruptedException e) {
                    break;
                }
            }
        } catch (Exception e) {
            logger.severe(e.getMessage());
        } finally {
            // destroy 程序运行结束时 销毁
            JobConfig.getInstance().destroyJobExecutor();
        }
    }
}
